﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using FrameWork.Interface;
using Slja.Model;
using FrameWork.Components;

namespace FrameWork.web.Web.UC
{
    public abstract class OrderSectionBase : System.Web.UI.UserControl, IOperateView, IControlDisplayUsage
    {

        private OrderExtModel _Order;
        /// <summary>
        /// 订单实体类
        /// </summary>
        public OrderExtModel Order
        {
            get { return _Order; }
            set { _Order = value; }
        }
        //OpRightState _OpRight;
        /// <summary>
        /// 操作权限
        /// </summary>
        public OpRightState OpRight
        {
            get {
                if (ViewState["_OpRight"] == null)
                {
                    ViewState["_OpRight"] = this.GetOpRight();
                }
                return (OpRightState)ViewState["_OpRight"];
            }
            set { ViewState["_OpRight"] = value; }
        }
        /// <summary>
        /// 当前是私有查看，还是否公共可见（默认私有""）
        /// </summary>
        public string ViewType
        {
            get
            {
                if (ViewState["_ViewType"] == null)
                {
                    ViewState["_ViewType"] = "";
                }
                return ViewState["_ViewType"].ToString().ToUpper();
            }
            set { ViewState["_ViewType"] = value; }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {               
                if (OpRight != OpRightState.Hidden)
                {
                    LoadData();
                }
            }
        }
        public abstract void SaveData();
        /// <summary>
        /// 取得超作权限
        /// </summary>
        /// <returns></returns>
        protected abstract OpRightState GetOpRight();
        /// <summary>
        /// 加载本控件的数据
        /// </summary>
        protected virtual void LoadData()
        {
        }
        private DisplayUsage _ControlUsage= DisplayUsage.DefaultDisplay;
        /// <summary>
        /// 控件用途（展示目标）
        /// </summary>
        public DisplayUsage ControlUsage
        {
            get
            {
                return _ControlUsage;
            }
            set
            {
                _ControlUsage = value;
            }
        }
    }
}